﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ShopOnline.Web;

namespace ShopOnline.Views
{
    public partial class MakeOrderChildWindow : ChildWindow
    {
        public Order NewOrder
        {
            get;
            private set;
        }

        public MakeOrderChildWindow(Order order)
        {
            InitializeComponent();

            this.NewOrder = order;
            this.DataContext = NewOrder;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.NewOrder.HasValidationErrors)
            {
                ErrorWindow err = new ErrorWindow("Cannot make order!", "Some data is invalid please check.");
                err.Show();
                return;
            }
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.NewOrder.CustomerName = String.Empty;
            this.NewOrder.Address = String.Empty;
            this.NewOrder.Phone = String.Empty;
            this.NewOrder.Email = String.Empty;
        }
    }
}

